package com.primecalc;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;

import com.timer.Timer;

public class PrimeCalcCloud {
	private long time;
	private String errorMessage;
	private String returnValue = "dude";
	
	public void primeInteract(String inUrl) {
		try {
			new Timer();
			Timer.reset();
			Timer.start();
			URL url = new URL(inUrl);
			BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
			String str;
			while((str = in.readLine()) != null) {
				this.returnValue = str;
			}
			in.close();
			Timer.stop();
			this.time = Timer.result();
		} catch (MalformedURLException e) {
			this.errorMessage = "PrimeInteract.primeInteract()" + e;
		} catch (IOException e) {
			this.errorMessage = "PrimeInteract.primeInteract()" + e;
		}
	}
	
	public String errorMessage() {
		return this.errorMessage;
	}
	
    public String returnNumber() {
		return this.returnValue;
    }
	
	public long returnTime() {
		return this.time;
	}    
}
